// Created by WXX on 2021/9/30 14:33
#include "MyTree.h"

/**
 * 执行用时：28 ms, 在所有 C++ 提交中击败了96.87%的用户
 * 内存消耗：34 MB, 在所有 C++ 提交中击败了52.03%的用户
 */
class Solution {
public:
    TreeNode *searchBST(TreeNode *root, int val) {
        if (!root || val == root->val) return root;
        if (val < root->val) return searchBST(root->left, val);
        return searchBST(root->right, val);
    }
};

int main() {

    int nu = INT_MAX;
    vector<int> nums = {
            4,
            2, 7,
            1, 3
    };
    TreeNode *root = MyTree(nums).getRoot();
    OutputBasicArray2D1(MyTree().levelOrder(Solution().searchBST(root, 2)));

    return 0;
}
